package com.vote.admin.controller;

import com.vote.admin.service.AdminMainService;
import com.vote.common.entity.VoteMenu;
import com.vote.common.returns.RespEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/admin-main")
@Slf4j
@Api(value = "管理平台主页", tags = "管理平台主页")
public class AdminMainController {

    @Resource
    private AdminMainService adminMainService;

    @GetMapping("/menu")
    @ApiOperation(value = "菜单列表")
    public RespEntity<List<VoteMenu>> queryAllMenus(HttpSession session) {
        RespEntity<List<VoteMenu>> respEntity = adminMainService.queryAllMenu(session);
        return respEntity;
    }

    @GetMapping("/welcome")
    @ApiOperation(value = "欢迎语")
    public RespEntity<String> welcome(HttpSession session) {
        RespEntity<String> respEntity = adminMainService.welcome(session);
        return respEntity;
    }

    @DeleteMapping("/exit")
    @ApiOperation(value = "退出登录")
    public RespEntity exit(HttpSession session) {
        RespEntity respEntity = adminMainService.signOut(session);
        return respEntity;
    }
}
